//package com.example.redisdemo.configuration;
//
//import com.example.redisdemo.properties.RedissonProp;
//import org.redisson.Redisson;
//import org.redisson.api.RedissonClient;
//import org.redisson.config.Config;
//import org.redisson.config.SentinelServersConfig;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.util.StringUtils;
//
///**
// * @author hexinglin
// * @created 2021-08-06 12:02
// **/
//@Configuration
//public class RedissonConfig {
//    @Autowired
//    private RedissonProp redssionProperties;
//
//
//     @Bean
//     @ConditionalOnProperty(name ="redisson.address")
//     public RedissonClient redissonClient() {
//                 Config config = new Config();
//                 config.useSingleServer()
//                         .setPassword(redssionProperties.getPassword())
//                         .setAddress("redis://"+redssionProperties.getAddress());
//
//                 RedissonClient redisson = Redisson.create(config);
//                 return redisson;
//             }
//    /**
//     * 哨兵模式自动装配
//     *
//     * @return
//     */
//    @Bean
//    @ConditionalOnProperty(name = "redisson.master-name")
//    RedissonClient redissonSentinel() {
//        Config config = new Config();
//        SentinelServersConfig serverConfig = config.useSentinelServers().addSentinelAddress(redssionProperties.getSentinelAddresses())
//                .setMasterName(redssionProperties.getMasterName())
//                .setTimeout(redssionProperties.getTimeout())
//                .setMasterConnectionPoolSize(redssionProperties.getMasterConnectionPoolSize())
//                .setSlaveConnectionPoolSize(redssionProperties.getSlaveConnectionPoolSize());
//
//        if (!StringUtils.isEmpty(redssionProperties.getPassword())) {
//            serverConfig.setPassword(redssionProperties.getPassword());
//        }
//        return Redisson.create(config);
//    }
//
//}
